package com.guigu.ssq.servlet;

import com.ly.common.util.DBHelper;

import java.util.List;
import java.util.Map;

public class DataDao {

    public List<Map<String, Object>> query(String date1, String date2, String pnum) {
      int pn =   Integer.parseInt(pnum) - 1;
        DBHelper db = new DBHelper();
        String sql = "select * from ssq_lottery where opendate between ? and ? limit " + pnum + ",10";
        if (db.selectListMap(sql, date1, date2) != null) {
            return db.selectListMap(sql, date1, date2);
        } else {
            return db.selectListMap(sql, date2, date1);
        }
    }

    public long count(String date1, String date2) {
        DBHelper db = new DBHelper();
        String sql = "select  *  from ssq_lottery where opendate between ? and ?";
        if (db.count(sql, date1, date2) != 0 || db.count(sql, date2, date1) != 0) {
            if (db.count(sql, date1, date2) != 0) {
                return db.count(sql, date1, date2);
            } else {
                return db.count(sql, date2, date1);
            }
        } else {
            return 0;
        }
    }
}
